/***********************************************************************
 * Module:  ImportantVehicleController.java
 * Author:  Administrator
 * Purpose: Defines the Class ImportantVehicleController
 ***********************************************************************/

package ishitong.vehicleManagement.controller;

import ishitong.vehicleManagement.model.ImportantVehicle;
import ishitong.common.SysCodeType;
import ishitong.common.model.SysCode;
import ishitong.commons.pagination.Pagination;
import ishitong.vehicleManagement.model.ImportantVehicleQuery;
import ishitong.vehicleManagement.service.biz.ImportantVehicleService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.ishitong.platform.common.page.Page;

/** @pdOid 94c49108-7289-4651-a833-58cb8d9dc602 */
@Controller
public class ImportantVehicleController extends ishitong.common.controller.ActionController {
   /** @pdOid 2e2842a8-2dff-4c92-a888-9c4740e08de1 */
   private static final String IMP_VEH_SCH = "vehicleManagement/importantVehicle/importantVehicleSearch";
   /** @pdOid 8559ce85-fbaf-4b08-ae22-900617bdcb07 */
   private static final String IMP_VEH_SCH_LST = "vehicleManagement/importantVehicle/importantVehicleSearchList";
   /** @pdOid a614aec3-006d-4af2-9d03-9c2f514c71bc */
   private static final String IMP_VEH_EDT = "vehicleManagement/importantVehicle/importantVehicleEdit";
   /** @pdOid b1be1e66-2915-4f7f-b3b7-26fbc85e9ad9 */
   private static final String IMP_VEH_VIW = "vehicleManagement/importantVehicle/importantVehicleView";
   /** @pdOid e2b6947f-0cc1-4756-982a-2026d7367d56 */
   private static final String IMP_VEH_AUD = "vehicleManagement/importantVehicle/importantVehicleAudit";
   /** @pdOid c5c56e6c-8cf7-4cff-bce0-0eb29732589a */
   @Autowired
   private ImportantVehicleService importantVehicleService;
   
   /** @param request
    * @exception Exception
    * @pdOid 716070e0-145d-43f0-99fd-48eb78d85481 */
   @RequestMapping(value = "/showImportantVehicleSearch.do")
   public ModelAndView handleShowImportantVehicleSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND); 
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   
   		// 审核状态
   		List<SysCode> lstAuditState = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.AUDIT_STATE);
   		model.put("lstAuditState", lstAuditState);
   		return new ModelAndView(IMP_VEH_SCH,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param importantVehicleQuery 
    * @param pagination
    * @pdOid 4bfdaf68-04da-4b39-b47a-a0e6d554f791 */
   @RequestMapping(value = "/ajaxImportantVehicleSearchList.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxFindImportantVehicleSelectList(HttpServletRequest request, ImportantVehicleQuery importantVehicleQuery, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		Page<ImportantVehicle> page = importantVehicleService.findPage(importantVehicleQuery, pagination.getPageSize(), pagination.getCurrentPage());
   		model.put("page", page);
   		return new ModelAndView(IMP_VEH_SCH_LST,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param importantVehicleId
    * @exception Exception
    * @pdOid 2a207844-14ff-4d2c-92a1-5b00b6a31ae7 */
   @RequestMapping(value = "/ajaxShowImportantVehicleEdit.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowImportantVehicleEdit(HttpServletRequest request, String importantVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND); 
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   
   		// 号牌颜色
   		List<SysCode> lstPlateColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_COLOR);
   		model.put("lstPlateColor", lstPlateColor);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   
   		// 车身颜色
   		List<SysCode> lstVehicleColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_COLOR);
   		model.put("lstVehicleColor", lstVehicleColor);
   
   		// 使用性质
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   
   		// 车辆分类
   		List<SysCode> lstVehicleClassification = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleClassification", lstVehicleClassification);
   
   		if(!StringUtils.isEmpty(importantVehicleId)){
   			ImportantVehicle importantVehicle = importantVehicleService.findById(importantVehicleId);
   			model.put("importantVehicle", importantVehicle);
   		}
   		return new ModelAndView(IMP_VEH_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param importantVehicle 
    * @param response
    * @exception Exception
    * @pdOid 43410c13-1b4f-4924-b12b-88ec74824ecb */
   @RequestMapping(value = "/ajaxSaveImportantVehicle.do", method = RequestMethod.POST)
   public void handleAjaxSaveImportantVehicle(HttpServletRequest request, ImportantVehicle importantVehicle, HttpServletResponse response) throws Exception {
   	try {
   		importantVehicleService.save(importantVehicle);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param importantVehicleId
    * @exception Exception
    * @pdOid 4b14ae60-fff5-459e-82b0-f4883122b931 */
   @RequestMapping(value = "/ajaxShowImportantVehicleView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowImportantVehicleView(HttpServletRequest request, String importantVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		if(!StringUtils.isEmpty(importantVehicleId)){
   			ImportantVehicle importantVehicle = importantVehicleService.findById(importantVehicleId);
   			model.put("importantVehicle", importantVehicle);
   		}
   		return new ModelAndView(IMP_VEH_VIW, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param importantVehicleIds 
    * @param response
    * @exception Exception
    * @pdOid 93e73bf6-ef30-45bc-b707-94a5269394d6 */
   @RequestMapping(value = "/ajaxDeleteImportantVehicleByIds.do", method = RequestMethod.POST)
   public void handleAjaxDeleteImportantVehicleByIds(HttpServletRequest request, String importantVehicleIds, HttpServletResponse response) throws Exception {
   	try {
   		importantVehicleService.delete(importantVehicleIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param importantVehicleId
    * @exception Exception
    * @pdOid 02fd3a4c-0b90-424c-8f03-2cda1a7618cc */
   @RequestMapping(value = "/ajaxRepealImportantVehicle.do", method = RequestMethod.POST)
   public ModelAndView ajaxRepealImportantVehicle(HttpServletRequest request, String importantVehicleId) throws Exception {
   	try {
   		return new ModelAndView(IMP_VEH_VIW);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param importantVehicleId
    * @exception Exception
    * @pdOid 792b117f-ea05-4530-914a-916166e20152 */
   @RequestMapping(value = "/ajaxShowImportantVehicleAudit.do", method = RequestMethod.POST)
   public ModelAndView ajaxShowImportantVehicleAudit(HttpServletRequest request, String importantVehicleId) throws Exception {
   	return new ModelAndView(IMP_VEH_AUD);
   }

}